#region " LICENSE "
// DRILL - Dependency Resolution Interface Layer Library
// Copyright (c) 2008-2012 Wade A. Reynolds. All rights reserved.
// http://drill.codeplex.com/
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using Drill.Configuration;
using Drill.Core;
using Drill.Core.MasterFactories;
using Drill.Extensibility;
using Drill.DrillBits.Unity.TestHelpers;
using Drill.TestSupport;
using Drill.TestSupport.TestDomains.AutomobileDomain;
using Drill.TestSupport.TestDomains.SimpleDomain;
using Microsoft.Practices.Unity;
using NUnit.Framework;
using Rhino.Mocks;

namespace Drill.DrillBits.Unity
{
	[TestFixture]
	public class UnityDrillBitTests
	{
		[Category("UnitTest")]
		[Test]
		public void CanConstructUsingConstructorWithInitializationContextParameter()
		{
			// Arrange
			IDrillBitInitContext initializationContext =
				UnityTestConfigs.CreateUnityProviderInitializationContext();

			// Act
			UnityDrillBit unityDrillBit = new UnityDrillBit(initializationContext);

			// Assert
			Assert.That(unityDrillBit, Is.Not.Null);
		}

		[Category("UnitTest")]
		[Test]
		public void CanConstructUsingParameterizedConstructor()
		{
			// Arrange
			IUnityContainer mockUnityContainer = MockRepository.GenerateStub<IUnityContainer>();

			// Act
			UnityDrillBit unityDrillBit = new UnityDrillBitTestClass(mockUnityContainer);
			
			// Assert
			Assert.That(unityDrillBit, Is.Not.Null);
		}

		[Category("UnitTest")]
		[ExpectedException(typeof(ArgumentNullException), ExpectedMessage = "container", MatchType = MessageMatch.Contains)]
		[Test]
		public void CannotConstructUsingParameterizedConstructorWithNullUnityContainerParameterValue()
		{
			// Arrange
			// Nothing to arrange

			// Act
			// ReSharper disable ObjectCreationAsStatement
			new UnityDrillBitTestClass(null);
			// ReSharper restore ObjectCreationAsStatement

			// Assert
			// Nothing to assert because the test should throw an expected exception (see ExpectedException attribute).
		}

		[Category("UnitTest")]
		[Test]
		public void CanCastAsIDrillBit()
		{
			// Arrange
			UnityDrillBit unityDrillBit = 
				new UnityDrillBit(new DrillBitInitContext());
			
			// Act
			// ReSharper disable RedundantCast
			IDrillBit containerProvider = unityDrillBit as IDrillBit;
			// ReSharper restore RedundantCast
			
			// Assert
			Assert.That(containerProvider, Is.Not.Null);
		}

		[Category("UnitTest")]
		[Test]
		public void CanCastAsIDependencyResolver()
		{
			// Arrange
			UnityDrillBit unityDrillBit = 
				new UnityDrillBit(new DrillBitInitContext());
			
			// Act
			// ReSharper disable RedundantCast
			IDependencyResolver containerProvider = unityDrillBit as IDependencyResolver;
			// ReSharper restore RedundantCast
			
			// Assert
			Assert.That(containerProvider, Is.Not.Null);
		}

		[Category("UnitTest")]
		[Test]
		public void CanGetInnerUnityContainerPropertyUsingDerivedClass()
		{
			// Arrange
			IUnityContainer mockUnityContainer = MockRepository.GenerateStub<IUnityContainer>();

			// Act
			UnityDrillBitTestClass drillBit = new UnityDrillBitTestClass(mockUnityContainer);
			
			// Assert
			Assert.That(drillBit.InnerUnityContainer, Is.Not.Null);
		}

		[Category("UnitTest")]
		[Test]
		public void CanDispose()
		{
			// Arrange
			UnityDrillBit unityDrillBit = 
				new UnityDrillBit(new DrillBitInitContext());

			// Verify Arrangement
			Assert.That(unityDrillBit.IsDisposed, Is.False);
			
			// Act
			unityDrillBit.Dispose();

			// Assert
			Assert.That(unityDrillBit.IsDisposed, Is.True);
		}

		[Category("UnitTest")]
		[Test]
		public void CanDisposeWhenConstructedWithInitializationContext()
		{
			// Arrange
			UnityDrillBit unityDrillBit = 
				new UnityDrillBit(new DrillBitInitContext());

			// Verify Arrangement
			Assert.That(unityDrillBit.IsDisposed, Is.False);

			// Act
			unityDrillBit.Dispose();

			// Assert
			Assert.That(unityDrillBit.IsDisposed, Is.True);
		}

		[Category("IntegrationTest")]
		[Test]
		public void CanDisposeWithIntegrationTestConfig()
		{
			// Arrange
			IDependencyResolverConfiguration config = TestConfigFileLoader.LoadDefaultTestConfig();
			
			IDrillChuckDependencyResolver dependencyResolver = 
				(IDrillChuckDependencyResolver)DependencyResolverManager.Create(config);
			
			UnityDrillBit unityDrillBit = 
				dependencyResolver.DrillBits[0] as UnityDrillBit;

			// Verify Arrangement
			// ReSharper disable PossibleNullReferenceException
			Assert.That(unityDrillBit, Is.Not.Null);
			Assert.That(unityDrillBit.IsDisposed, Is.False);
			// ReSharper restore PossibleNullReferenceException

			// Act
			unityDrillBit.Dispose();

			// Assert
			Assert.That(unityDrillBit.IsDisposed, Is.True);
		}

		[Category("UnitTest")]
		[ExpectedException(typeof(ObjectDisposedException), ExpectedMessage = "has been disposed", MatchType = MessageMatch.Contains)]
		[Test]
		public void CannotInvokeInnerContainerAfterDispose()
		{
			// Arrange
			IUnityContainer mockUnityContainer = MockRepository.GenerateStub<IUnityContainer>();
			UnityDrillBitTestClass drillBit = new UnityDrillBitTestClass(mockUnityContainer);
			Assert.That(drillBit.IsDisposed, Is.False);
			drillBit.Dispose();

			// Act
			// ReSharper disable UnusedVariable
			var container = drillBit.InnerUnityContainer;
			// ReSharper restore UnusedVariable

			// Assert
			// Nothing to assert because the test should throw an expected exception (see ExpectedException attribute).
		}

		[Category("UnitTest")]
		[ExpectedException(typeof(ObjectDisposedException), ExpectedMessage = "has been disposed", MatchType = MessageMatch.Contains)]
		[Test]
		public void CannotInvokeGetAllInstancesAfterDispose()
		{
			// Arrange
			IUnityContainer mockUnityContainer = MockRepository.GenerateStub<IUnityContainer>();
			UnityDrillBit unityDrillBit = new UnityDrillBitTestClass(mockUnityContainer);
			Assert.That(unityDrillBit.IsDisposed, Is.False);
			unityDrillBit.Dispose();
			IDependencyResolver dependencyResolver = unityDrillBit;

			// Act
			dependencyResolver.GetAllInstances(typeof(IVehicle));

			// Assert
			// Nothing to assert because the test should throw an expected exception (see ExpectedException attribute).
		}

		[Category("UnitTest")]
		[ExpectedException(typeof(ObjectDisposedException), ExpectedMessage = "has been disposed", MatchType = MessageMatch.Contains)]
		[Test]
		public void CannotInvokeGetAllInstancesGenericAfterDispose()
		{
			// Arrange
			IUnityContainer mockUnityContainer = MockRepository.GenerateStub<IUnityContainer>();
			UnityDrillBit unityDrillBit = new UnityDrillBitTestClass(mockUnityContainer);
			Assert.That(unityDrillBit.IsDisposed, Is.False);
			unityDrillBit.Dispose();
			IDependencyResolver dependencyResolver = unityDrillBit;

			// Act
			dependencyResolver.GetAllInstances<IVehicle>();

			// Assert
			// Nothing to assert because the test should throw an expected exception (see ExpectedException attribute).
		}

		[Category("UnitTest")]
		[ExpectedException(typeof(ObjectDisposedException), ExpectedMessage = "has been disposed", MatchType = MessageMatch.Contains)]
		[Test]
		public void CannotInvokeGetInstanceAfterDispose()
		{
			// Arrange
			IUnityContainer mockUnityContainer = MockRepository.GenerateStub<IUnityContainer>();
			UnityDrillBit unityDrillBit = new UnityDrillBitTestClass(mockUnityContainer);
			Assert.That(unityDrillBit.IsDisposed, Is.False);
			unityDrillBit.Dispose();
			IDependencyResolver dependencyResolver = unityDrillBit;

			// Act
			dependencyResolver.GetInstance(typeof (IVehicle));

			// Assert
			// Nothing to assert because the test should throw an expected exception (see ExpectedException attribute).
		}

		[Category("UnitTest")]
		[ExpectedException(typeof(ObjectDisposedException), ExpectedMessage = "has been disposed", MatchType = MessageMatch.Contains)]
		[Test]
		public void CannotInvokeGetInstanceGenericAfterDispose()
		{
			// Arrange
			IUnityContainer mockUnityContainer = MockRepository.GenerateStub<IUnityContainer>();
			UnityDrillBit unityDrillBit = new UnityDrillBitTestClass(mockUnityContainer);
			Assert.That(unityDrillBit.IsDisposed, Is.False);
			unityDrillBit.Dispose();
			IDependencyResolver dependencyResolver = unityDrillBit;

			// Act
			dependencyResolver.GetInstance<IVehicle>();

			// Assert
			// Nothing to assert because the test should throw an expected exception (see ExpectedException attribute).
		}

		[Category("UnitTest")]
		[ExpectedException(typeof(ObjectDisposedException), ExpectedMessage = "has been disposed", MatchType = MessageMatch.Contains)]
		[Test]
		public void CannotInvokeGetInstanceByTypeAndNameAfterDispose()
		{
			// Arrange
			IUnityContainer mockUnityContainer = MockRepository.GenerateStub<IUnityContainer>();
			UnityDrillBit unityDrillBit = new UnityDrillBitTestClass(mockUnityContainer);
			Assert.That(unityDrillBit.IsDisposed, Is.False);
			unityDrillBit.Dispose();
			IDependencyResolver dependencyResolver = unityDrillBit;

			// Act
			dependencyResolver.GetInstance(typeof(IVehicle), "car");

			// Assert
			// Nothing to assert because the test should throw an expected exception (see ExpectedException attribute).
		}

		[Category("UnitTest")]
		[ExpectedException(typeof(ObjectDisposedException), ExpectedMessage = "has been disposed", MatchType = MessageMatch.Contains)]
		[Test]
		public void CannotInvokeGetInstanceByTypeAndNameGenericAfterDispose()
		{
			// Arrange
			IUnityContainer mockUnityContainer = MockRepository.GenerateStub<IUnityContainer>();
			UnityDrillBit unityDrillBit = new UnityDrillBitTestClass(mockUnityContainer);
			Assert.That(unityDrillBit.IsDisposed, Is.False);
			unityDrillBit.Dispose();
			IDependencyResolver dependencyResolver = unityDrillBit;

			// Act
			dependencyResolver.GetInstance<IVehicle>("car");

			// Assert
			// Nothing to assert because the test should throw an expected exception (see ExpectedException attribute).
		}

		[Category("UnitTest")]
		[ExpectedException(typeof(ObjectDisposedException), ExpectedMessage = "has been disposed", MatchType = MessageMatch.Contains)]
		[Test]
		public void CannotInvokeResolverObjectAfterDispose()
		{
			// Arrange
			IUnityContainer mockUnityContainer = MockRepository.GenerateStub<IUnityContainer>();
			UnityDrillBitTestClass drillBit = new UnityDrillBitTestClass(mockUnityContainer);
			Assert.That(drillBit.IsDisposed, Is.False);
			drillBit.Dispose();

			// Act
			// ReSharper disable UnusedVariable
			var container = drillBit.ResolverObject;
			// ReSharper restore UnusedVariable

			// Assert
			// Nothing to assert because the test should throw an expected exception (see ExpectedException attribute).
		}

		[Category("UnitTest")]
		[Test]
		public void CanGetInstanceByType()
		{
			// Arrange
			IUnityContainer mockUnityContainer = MockRepository.GenerateStub<IUnityContainer>();

			mockUnityContainer.Stub(c => c.Resolve(typeof(IVehicle)))
							  .Return(new Car())
							  .Repeat.Any();

			IDependencyResolver dependencyResolver = new UnityDrillBitTestClass(mockUnityContainer);

			// Act
			IVehicle vehicle = dependencyResolver.GetInstance(typeof(IVehicle)) as IVehicle;

			// Assert
			Assert.That(vehicle, Is.Not.Null);
			Assert.That(vehicle, Is.TypeOf(typeof(Car)));
		}

		[Category("UnitTest")]
		[Test]
		public void CanGetInstanceByTypeGeneric()
		{
			// Arrange
			IUnityContainer mockUnityContainer = MockRepository.GenerateStub<IUnityContainer>();

			mockUnityContainer.Stub(c => c.Resolve(typeof(IVehicle)))
							  .Return(new Car())
							  .Repeat.Any();

			IDependencyResolver dependencyResolver = new UnityDrillBitTestClass(mockUnityContainer);

			// Act
			IVehicle vehicle = dependencyResolver.GetInstance<IVehicle>();

			// Assert
			Assert.That(vehicle, Is.Not.Null);
			Assert.That(vehicle, Is.TypeOf(typeof(Car)));
		}

		[Category("IntegrationTest")]
		[Test]
		public void CanGetInstanceByTypeGenericWhenConfiguredWithConfigFileConfigurationSource()
		{
			// Arrange
			IDependencyResolverConfiguration config =
				UnityTestConfigs.CreateUnityDependencyResolverConfigurationWithConfigFileConfigurationSource();

			IDrillChuckDependencyResolver drillChuckDependencyResolver =
				(IDrillChuckDependencyResolver) new ConfigBasedMasterDependencyResolverFactory(config).CreateDependencyResolver();

			IDependencyResolver dependencyResolver = drillChuckDependencyResolver.DrillBits[0];

			// Act
			ITestObjA testObjA = dependencyResolver.GetInstance<ITestObjA>();

			// Assert
			Assert.That(testObjA, Is.Not.Null);
			Assert.That(testObjA, Is.TypeOf(typeof(TestObjA)));
		}

		[Category("IntegrationTest")]
		[ExpectedException(
			typeof(UnityDrillBitException)
		  , ExpectedMessage = "missing or misnamed config section or because the default config file could not be found"
		  , MatchType = MessageMatch.Contains)
			]
		[Test]
		public void CannotGetInstanceByTypeGenericWhenConfiguredWithConfigFileConfigurationSourceAndConfigIsMissing()
		{
			// Arrange
			using (AppConfig.ChangeToEmptyConfig())
			{
				IDependencyResolverConfiguration config =
					UnityTestConfigs.CreateUnityDependencyResolverConfigurationWithConfigFileConfigurationSource();

				IDrillChuckDependencyResolver drillChuckDependencyResolver =
					(IDrillChuckDependencyResolver)new ConfigBasedMasterDependencyResolverFactory(config).CreateDependencyResolver();

				IDependencyResolver dependencyResolver = drillChuckDependencyResolver.DrillBits[0];

				// Act
				dependencyResolver.GetInstance<ITestObjA>();

				// Assert
				// Nothing to assert because the test should throw an expected exception (see ExpectedException attribute).
			}
		}

		[Category("IntegrationTest")]
		[Test]
		public void CanGetInstanceByTypeGenericWhenConfiguredWithSetupProvider()
		{
			// Arrange
			IDependencyResolverConfiguration config =
				UnityTestConfigs.CreateUnityDependencyResolverConfigurationWithSetupProvider();

			IDrillChuckDependencyResolver drillChuckDependencyResolver =
				(IDrillChuckDependencyResolver)new ConfigBasedMasterDependencyResolverFactory(config).CreateDependencyResolver();

			IDependencyResolver dependencyResolver = drillChuckDependencyResolver.DrillBits[0];

			// Act
			IVehicle vehicle = dependencyResolver.GetInstance<IVehicle>();

			// Assert
			Assert.That(vehicle, Is.Not.Null);
			Assert.That(vehicle, Is.TypeOf(typeof(Car)));
		}

		[Category("IntegrationTest")]
		[Test]
		public void CanGetInstanceByTypeGenericWhenConfiguredWithDefaultConfigurationSource()
		{
			// Arrange
			IDependencyResolverConfiguration config =
				UnityTestConfigs.CreateUnityDependencyResolverConfigurationWithDefaultConfigurationSource();

			IDrillChuckDependencyResolver drillChuckDependencyResolver =
				(IDrillChuckDependencyResolver)new ConfigBasedMasterDependencyResolverFactory(config).CreateDependencyResolver();

			IDependencyResolver dependencyResolver = drillChuckDependencyResolver.DrillBits[0];

			// Act
			ITestObjA testObjA = dependencyResolver.GetInstance<ITestObjA>();

			// Assert
			Assert.That(testObjA, Is.Not.Null);
			Assert.That(testObjA, Is.TypeOf(typeof(TestObjA)));
		}

		[Category("IntegrationTest")]
		[ExpectedException(
			typeof(UnityDrillBitException)
		  , ExpectedMessage = "missing or misnamed config section or because the default config file could not be found"
		  , MatchType = MessageMatch.Contains)
			]
		[Test]
		public void CannotGetInstanceByTypeGenericWhenConfiguredWithDefaultConfigurationSourceAndConfigIsMissing()
		{
			// Arrange
			using (AppConfig.ChangeToEmptyConfig())
			{
				IDependencyResolverConfiguration config =
					UnityTestConfigs.CreateUnityDependencyResolverConfigurationWithDefaultConfigurationSource();

				IDrillChuckDependencyResolver drillChuckDependencyResolver =
					(IDrillChuckDependencyResolver)new ConfigBasedMasterDependencyResolverFactory(config).CreateDependencyResolver();

				IDependencyResolver dependencyResolver = drillChuckDependencyResolver.DrillBits[0];

				// Act
				dependencyResolver.GetInstance<ITestObjA>();

				// Assert
				// Nothing to assert because the test should throw an expected exception (see ExpectedException attribute).
			}
		}

		[Category("UnitTest")]
		[Test]
		public void CanGetInstanceByTypeAndName()
		{
			// Arrange
			IUnityContainer mockUnityContainer = MockRepository.GenerateStub<IUnityContainer>();
			
			mockUnityContainer.Stub(c => c.Resolve(typeof(IVehicle), "car"))
							  .Return(new Car())
							  .Repeat.Any();

			mockUnityContainer.Stub(c => c.Resolve(typeof(IVehicle), "truck"))
							  .Return(new Truck())
							  .Repeat.Any();

			IDependencyResolver dependencyResolver = new UnityDrillBitTestClass(mockUnityContainer);

			// Act
			IVehicle vehicle = dependencyResolver.GetInstance(typeof(IVehicle), "car") as IVehicle;

			// Assert
			Assert.That(vehicle, Is.Not.Null);
			Assert.That(vehicle, Is.TypeOf(typeof(Car)));

			// Act
			vehicle = dependencyResolver.GetInstance(typeof(IVehicle), "truck") as IVehicle;

			// Assert
			Assert.That(vehicle, Is.Not.Null);
			Assert.That(vehicle, Is.TypeOf(typeof(Truck)));
		}

		[Category("UnitTest")]
		[Test]
		public void CanGetInstanceByTypeAndNameGeneric()
		{
			// Arrange
			IUnityContainer mockUnityContainer = MockRepository.GenerateStub<IUnityContainer>();

			mockUnityContainer.Stub(c => c.Resolve(typeof(IVehicle), "car"))
							  .Return(new Car())
							  .Repeat.Any();

			mockUnityContainer.Stub(c => c.Resolve(typeof(IVehicle), "truck"))
							  .Return(new Truck())
							  .Repeat.Any();

			IDependencyResolver dependencyResolver = new UnityDrillBitTestClass(mockUnityContainer);

			// Act
			IVehicle vehicle = dependencyResolver.GetInstance(typeof(IVehicle), "car") as IVehicle;

			// Assert
			Assert.That(vehicle, Is.Not.Null);
			Assert.That(vehicle, Is.TypeOf(typeof(Car)));

			// Act
			vehicle = dependencyResolver.GetInstance<IVehicle>("truck");

			// Assert
			Assert.That(vehicle, Is.Not.Null);
			Assert.That(vehicle, Is.TypeOf(typeof(Truck)));
		}

		[Category("UnitTest")]
		[Test]
		public void CanGetAllInstances()
		{
			// Arrange
			IUnityContainer mockUnityContainer = MockRepository.GenerateStub<IUnityContainer>();
			mockUnityContainer.Stub(c => c.ResolveAll(typeof(IVehicle)))
							  .Return(new IVehicle[] { new Car(), new Truck() })
							  .Repeat.Any();

			IDependencyResolver dependencyResolver = new UnityDrillBitTestClass(mockUnityContainer);

			// Act
			IEnumerable<IVehicle> vehicles = dependencyResolver.GetAllInstances(typeof(IVehicle)).Cast<IVehicle>();

			// Assert
			// ReSharper disable PossibleMultipleEnumeration
			Assert.That(vehicles.Count(), Is.EqualTo(2));
			Assert.That(vehicles.Any(o => o is Car), Is.True);
			Assert.That(vehicles.Any(o => o is Truck), Is.True);
			// ReSharper restore PossibleMultipleEnumeration
		}

		[Category("UnitTest")]
		[Test]
		public void CanGetAllInstancesGeneric()
		{
			// Arrange
			IUnityContainer mockUnityContainer = MockRepository.GenerateStub<IUnityContainer>();
			mockUnityContainer.Stub(c => c.ResolveAll<IVehicle>())
							  .Return(new IVehicle[] { new Car(), new Truck() })
							  .Repeat.Any();

			IDependencyResolver dependencyResolver = new UnityDrillBitTestClass(mockUnityContainer);

			// Act
			IEnumerable<IVehicle> vehicles = from v in dependencyResolver.GetAllInstances<IVehicle>() select v;

			// Assert
			// ReSharper disable PossibleMultipleEnumeration
			Assert.That(vehicles.Count(), Is.EqualTo(2));
			Assert.That(vehicles.Any(o => o is Car), Is.True);
			Assert.That(vehicles.Any(o => o is Truck), Is.True);
			// ReSharper restore PossibleMultipleEnumeration
		}

		[Category("UnitTest")]
		[ExpectedException(typeof(ArgumentNullException), ExpectedMessage = "targetType", MatchType = MessageMatch.Contains)]
		[Test]
		public void CannotGetAllInstancesWithNullTypeArgument()
		{
			// Arrange
			IUnityContainer mockUnityContainer = MockRepository.GenerateStub<IUnityContainer>();
			IDependencyResolver dependencyResolver = new UnityDrillBitTestClass(mockUnityContainer);
			Type targetType = null;

			// Act
			// ReSharper disable ExpressionIsAlwaysNull
			dependencyResolver.GetAllInstances(targetType);
			// ReSharper restore ExpressionIsAlwaysNull

			// Assert
			// Nothing to assert because the test should throw an expected exception (see ExpectedException attribute).
		}

		[Category("UnitTest")]
		[ExpectedException(typeof(ArgumentNullException), ExpectedMessage = "targetType", MatchType = MessageMatch.Contains)]
		[Test]
		public void CannotGetInstanceByTypeWithNullTypeArgument()
		{
			// Arrange
			IUnityContainer mockUnityContainer = MockRepository.GenerateStub<IUnityContainer>();
			IDependencyResolver dependencyResolver = new UnityDrillBitTestClass(mockUnityContainer);
			Type targetType = null;

			// Act
			// ReSharper disable ExpressionIsAlwaysNull
			dependencyResolver.GetInstance(targetType);
			// ReSharper restore ExpressionIsAlwaysNull

			// Assert
			// Nothing to assert because the test should throw an expected exception (see ExpectedException attribute).
		}

		[Category("UnitTest")]
		[ExpectedException(typeof(ArgumentNullException), ExpectedMessage = "targetType", MatchType = MessageMatch.Contains)]
		[Test]
		public void CannotGetInstanceByTypeAndNameWithNullTypeArgument()
		{
			// Arrange
			IUnityContainer mockUnityContainer = MockRepository.GenerateStub<IUnityContainer>();
			IDependencyResolver dependencyResolver = new UnityDrillBitTestClass(mockUnityContainer);
			Type targetType = null;

			// Act
			// ReSharper disable ExpressionIsAlwaysNull
			dependencyResolver.GetInstance(targetType, "car");
			// ReSharper restore ExpressionIsAlwaysNull

			// Assert
			// Nothing to assert because the test should throw an expected exception (see ExpectedException attribute).
		}
	}
}
